return app;
}
+/**
+ * shell_app_system_get_app_for_window:
+ * @self: A #ShellAppSystem
+ * @window: A #MetaWindow
+ *
+ * Find or create a #ShellApp for window
+ *
+ * Return value: (transfer full): The #ShellApp for window, or %NULL if none
+ */
+ShellApp *
+shell_app_system_get_app_for_window (ShellAppSystem *self,
+ MetaWindow *window)
+{
+ char *id = g_strdup_printf ("window:%p", window);
+ ShellApp *app = g_hash_table_lookup (self->priv->app_id_to_app, id);
+
+ if (app)
+ g_object_ref (G_OBJECT (app));
+ else
+ app = _shell_app_new_for_window (window);
+
+ g_free (id);
+
+ return app;
+}
+
/* ShellAppSystem ensures we have a unique instance of
* apps per id.
*/
ShellAppInfo *shell_app_system_load_from_desktop_file (ShellAppSystem *system, const char *filename, GError **error);
ShellApp *shell_app_system_get_app (ShellAppSystem *system, const char *id);
+ShellApp *shell_app_system_get_app_for_window (ShellAppSystem *self, MetaWindow *window);
void _shell_app_system_register_app (ShellAppSystem *self, ShellApp *app);
char *wmclass;
char *with_desktop;
+ appsys = shell_app_system_get_default ();
wmclass = get_appid_from_window (window);
if (!wmclass)
- return _shell_app_new_for_window (window);
+ return shell_app_system_get_app_for_window (appsys, window);
with_desktop = g_strjoin (NULL, wmclass, ".desktop", NULL);
g_free (wmclass);
- appsys = shell_app_system_get_default ();
app = shell_app_system_lookup_heuristic_basename (appsys, with_desktop);
g_free (with_desktop);
}
if (app == NULL)
- {
- app = _shell_app_new_for_window (window);
- }
+ app = shell_app_system_get_app_for_window (appsys, window);
return app;
}